package sburb;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import java.util.*;

public class sburb {
	static List<Image> renderList = new ArrayList<Image>();

	public static void main(String[] argv) {
		System.out.println("Loading SBURB...");
		Display.setTitle("SBURB");

		initGL(900,600);		
		
		// init renderable objects here
		System.out.println(renderList);
		addImage("images/sword.png", 650, 194);
		Image Logo = addImage("images/logo.png", 350, 194);
		System.out.println(renderList);
		
		while (!Display.isCloseRequested()) {
			// render OpenGL here
			GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); // This wipes the screen to avoid repeating textures
			for (Image img : renderList) {
				img.drawTexture();
			}
			Display.update(); // Flash the write buffer to the graphics card
			Display.sync(60); // Wait however many ms we need to, to average 60fps
		}
		
		Display.destroy();
	}
	
	private static void initGL(int width, int height) {
		try {
			Display.setDisplayMode(new DisplayMode(width,height));
			Display.create();
		} catch (LWJGLException e) {
			e.printStackTrace();
			System.exit(0);
		}
		// I DON'T KNOW WHAT THESE DO BUT THEY'RE NEEDED LOL
		GL11.glEnable(GL11.GL_TEXTURE_2D);               
        
		GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);          
        
        	// enable alpha blending
        	GL11.glEnable(GL11.GL_BLEND);
        	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        
        	GL11.glViewport(0,0,width,height);
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
		
		GL11.glMatrixMode(GL11.GL_PROJECTION);
		GL11.glLoadIdentity();
		GL11.glOrtho(0, width, height, 0, 1, -1);
		GL11.glMatrixMode(GL11.GL_MODELVIEW);
	}

	static Image addImage(String Path, int X, int Y) {
		Image img = new Image(Path, X, Y);
		renderList.add(img);
		return img;
	}
}
